<?php
abstract class Pageley_Domain_AbstractCompositeValue implements Pageley_Domain_CompositeValue{

    private $properties;
    private $attribute;

    public function __construct($properties, $attribute) {
        if($properties === null) {
        	throw new Pageley_Util_IllegalArgumentException("Properties cannot be null");
        }
        if($properties === null) {
            throw new Pageley_Util_IllegalArgumentException("Attribute cannot be null");
        }
    	$this->properties = $properties;
        $this->attribute = $attribute;
    }

    public function get($propertyName) {
		$value = null;
        $subpropertyName = null;
        if(Pageley_Util_String::contains($propertyName, ".")) {
            $subpropertyName = Pageley_Util_String::substringAfter($propertyName, ".");
            $propertyName = Pageley_Util_String::substringBefore($propertyName, ".");
        }
        $value = $this->properties->get($propertyName);
        if($subpropertyName !== null) {
            $value = $value->get($subpropertyName);
        }
        return $value;
    }

    public function __toString() {
    	return $this->properties->__toString();
    }
}